<template>
    <!-- 新增|刷新  -->
    <div class="noticeBody">
        <div>
            <el-button type="primary" v-if="btns.includes('create')" size="small" @click="$emit('create')">新增</el-button>
            <el-popconfirm v-if="btns.includes('delete')" title="是否删除选中记录" confirmButtonText="确认" cancelButtonText="取消"
                @confirm.stop="$emit('delete')">
                <template #reference>
                    <el-button type="danger" size="small">批量删除</el-button>
                </template>
            </el-popconfirm>
            <slot></slot>
        </div>
        <div>
            <el-tooltip effect="dark" content="刷新数据" placement="top" v-if="btns.includes('refresh')">
                <el-button text @click="$emit('refresh')" size="small">
                    <el-icon :size="15">
                        <Refresh></Refresh>
                    </el-icon>
                </el-button>
            </el-tooltip>
            <el-tooltip effect="dark" content="导出数据" placement="top" v-if="btns.includes('download')">
                <el-button text @click="$emit('download')" size="small">
                    <el-icon :size="15">
                        <Download></Download>
                    </el-icon>
                </el-button>
            </el-tooltip>
        </div>
    </div>
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
    layout: {
        type: String,
        default: "create, refresh"
    }
})

const btns = computed(() => props.layout.split(","))
console.log(btns.value);
defineEmits(["create", "refresh", "delete", "download"])
</script>
<style scoped lang="less">
.noticeBody {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;

}
</style>